package org.tuskit.command {
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    import org.tuskit.business.MembershipDelegate;
    import org.tuskit.model.TuskitModelLocator;
    
    import mx.controls.Alert;
    import mx.rpc.IResponder;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    
    public class ListMembershipsCommand implements ICommand, IResponder {
        public function ListMemberships():void {     
        }

        public function execute(event : CairngormEvent) : void {
            var delegate : MembershipDelegate = new MembershipDelegate(this);
            delegate.listMemberships();
        }

        public function result(event : Object) : void {
            var result:XMLList = XMLList(event.result).children();
            var model : TuskitModelLocator = TuskitModelLocator.getInstance();
 			model.setMemberships(result);
 			model.isInTransitionState = false;
        }
    
        public function fault(event : Object) : void {
            tuskit.debug("CreateSessionCommand#fault, event = " + event);
            var faultEvent : FaultEvent = FaultEvent(event);
            Alert.show("Cannot get list of memberships");
        }
    }
}